package ua.keeper.query;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;

public class WeekListActivity extends ListActivity
{
	private WeekList list_;
	private WeekListAdapter adapter_;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    	super.onCreate(savedInstanceState);
    	
    	QueryApp appState = ((QueryApp)getApplicationContext());
    	list_ = new WeekList(appState.getDataBase());
    	
    	adapter_ = new WeekListAdapter(this, R.layout.week_list_row, list_.list);
        
        setListAdapter(adapter_);
    }
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id)
    {
    	int day_id = adapter_.getItem(position).getDayId();
    	if (day_id == 7)
    	{
    		Toast.makeText(this, "<В РАЗРАБОТКЕ>", Toast.LENGTH_SHORT).show();
    	}
    	else
    	{
    		Intent myIntent = new Intent(WeekListActivity.this, ClientListActivity.class);
        	myIntent.putExtra("dayOfWeek", Integer.toString(day_id));
        	WeekListActivity.this.startActivity(myIntent);
    	}
    }
}
